```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>工厂设计模式：创建对象的智慧抽象</title>
    <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css">
    <link rel="stylesheet" href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
        }
        h1, h2, h3, h4 {
            font-family: 'Noto Serif SC', serif;
            font-weight: 600;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #6B73FF 0%, #000DFF 50%, #0085FF 100%);
        }
        .card-hover {
            transition: all 0.3s ease;
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .code-block {
            background-color: #282c34;
            color: #abb2bf;
            border-radius: 8px;
            overflow-x: auto;
        }
        .keyword {
            color: #c678dd;
        }
        .class {
            color: #e5c07b;
        }
        .string {
            color: #98c379;
        }
        .comment {
            color: #5c6370;
            font-style: italic;
        }
        .method {
            color: #61afef;
        }
        .type {
            color: #56b6c2;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <div class="hero-gradient text-white py-20 px-4 sm:px-6 lg:px-8">
        <div class="max-w-4xl mx-auto text-center">
            <div class="flex justify-center mb-6">
                <span class="text-sm font-semibold tracking-wider uppercase px-3 py-1 bg-white bg-opacity-20 rounded-full">设计模式系列</span>
            </div>
            <h1 class="text-4xl md:text-5xl font-bold leading-tight mb-6">工厂设计模式：创建对象的智慧抽象</h1>
            <p class="text-xl md:text-2xl opacity-90 mb-8">将对象的创建与使用分离，实现优雅灵活的系统架构</p>
            <div class="flex justify-center space-x-4">
                <a href="#overview" class="px-6 py-3 bg-white text-blue-600 font-medium rounded-lg hover:bg-gray-100 transition duration-300">
                    <i class="fas fa-book-open mr-2"></i>开始阅读
                </a>
                <a href="#example" class="px-6 py-3 border border-white text-white font-medium rounded-lg hover:bg-white hover:bg-opacity-10 transition duration-300">
                    <i class="fas fa-code mr-2"></i>查看示例
                </a>
            </div>
        </div>
    </div>

    <!-- Main Content -->
    <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8 py-16">
        <!-- Overview Section -->
        <section id="overview" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-1 h-12 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">模式概述</h2>
            </div>
            <p class="text-lg text-gray-700 mb-6">工厂设计模式是一种创建型设计模式，它提供了一种方法来创建对象，而无需直接实例化对象。通过使用工厂模式，我们能够将对象的创建和使用进行解耦，从而提高系统的灵活性和可维护性。</p>
            
            <!-- Visual Guide -->
            <div class="bg-white rounded-xl shadow-md p-6 mb-10 card-hover">
                <div class="flex items-center mb-4">
                    <i class="fas fa-lightbulb text-yellow-500 text-2xl mr-3"></i>
                    <h3 class="text-xl font-semibold">为什么需要工厂模式？</h3>
                </div>
                <div class="grid md:grid-cols-3 gap-6">
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <div class="text-blue-500 mb-2">
                            <i class="fas fa-cogs text-3xl"></i>
                        </div>
                        <h4 class="font-semibold mb-2">复杂对象创建</h4>
                        <p class="text-gray-600 text-sm">当对象创建过程复杂，涉及多个步骤或条件判断时，工厂模式能有效封装这些细节</p>
                    </div>
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <div class="text-blue-500 mb-2">
                            <i class="fas fa-project-diagram text-3xl"></i>
                        </div>
                        <h4 class="font-semibold mb-2">代码解耦</h4>
                        <p class="text-gray-600 text-sm">将对象创建与使用分离，提高代码灵活性和可维护性</p>
                    </div>
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <div class="text-blue-500 mb-2">
                            <i class="fas fa-sitemap text-3xl"></i>
                        </div>
                        <h4 class="font-semibold mb-2">统一管理</h4>
                        <p class="text-gray-600 text-sm">对对象创建进行统一管理，如对象池、资源管理等场景</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Features Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-1 h-12 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">核心特点</h2>
            </div>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-sm p-6 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="bg-blue-100 p-3 rounded-full mr-4">
                            <i class="fas fa-box text-blue-600"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-2">封装对象创建过程</h3>
                            <p class="text-gray-600">工厂模式将对象的创建逻辑封装在一个工厂类中，客户端只需要调用工厂的方法即可获取所需对象。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-sm p-6 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="bg-purple-100 p-3 rounded-full mr-4">
                            <i class="fas fa-eye-slash text-purple-600"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-2">隐藏具体实现</h3>
                            <p class="text-gray-600">客户端无需关心对象的具体实现细节，只需要使用工厂提供的接口即可。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-sm p-6 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="bg-green-100 p-3 rounded-full mr-4">
                            <i class="fas fa-recycle text-green-600"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-2">代码复用</h3>
                            <p class="text-gray-600">工厂模式能够将对象的创建逻辑集中管理，避免了重复的代码，提高了代码的复用性。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-white rounded-xl shadow-sm p-6 card-hover">
                    <div class="flex items-start mb-4">
                        <div class="bg-red-100 p-3 rounded-full mr-4">
                            <i class="fas fa-exchange-alt text-red-600"></i>
                        </div>
                        <div>
                            <h3 class="text-xl font-semibold mb-2">灵活扩展</h3>
                            <p class="text-gray-600">新增产品类型时，只需扩展工厂类，无需修改已有代码，符合开闭原则。</p>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Application Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-1 h-12 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">应用场景</h2>
            </div>
            
            <div class="bg-white rounded-xl shadow-md overflow-hidden">
                <div class="p-6">
                    <div class="flex items-center mb-6">
                        <i class="fas fa-map-marked-alt text-blue-500 text-2xl mr-3"></i>
                        <h3 class="text-xl font-semibold">框架中的应用</h3>
                    </div>
                    
                    <div class="grid md:grid-cols-2 gap-6">
                        <div class="border-l-4 border-blue-500 pl-4">
                            <h4 class="font-bold text-lg mb-2">Spring框架</h4>
                            <p class="text-gray-600">Spring中的Bean工厂就是工厂模式的一个应用，通过配置文件或注解，Spring管理了对象的创建和生命周期。</p>
                        </div>
                        <div class="border-l-4 border-blue-500 pl-4">
                            <h4 class="font-bold text-lg mb-2">JDBC</h4>
                            <p class="text-gray-600">JDBC中的Connection对象的创建也使用了工厂模式，不同的数据库驱动对Connection的创建方式有所不同。</p>
                        </div>
                    </div>
                </div>
                
                <div class="bg-gray-50 p-6 border-t border-gray-200">
                    <div class="flex items-center">
                        <div class="bg-blue-100 p-2 rounded-full mr-4">
                            <i class="fas fa-lightbulb text-blue-600"></i>
                        </div>
                        <p class="text-gray-700">当您发现代码中有大量相似的对象创建逻辑，或者需要灵活切换不同的对象实现时，工厂模式可能是您的理想选择。</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Example Section -->
        <section id="example" class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-1 h-12 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">实现示例</h2>
            </div>
            
            <p class="text-lg text-gray-700 mb-6">以下是一个简单的工厂模式示例，创建不同类型的汽车：</p>
            
            <div class="code-block p-6 mb-8 rounded-lg">
                <pre class="text-sm"><code><span class="keyword">// 接口</span>
<span class="keyword">interface</span> <span class="class">Car</span> {
    <span class="keyword">void</span> <span class="method">drive</span>();
}

<span class="keyword">// 具体实现类</span>
<span class="keyword">class</span> <span class="class">SedanCar</span> <span class="keyword">implements</span> <span class="class">Car</span> {
    <span class="keyword">public</span> <span class="keyword">void</span> <span class="method">drive</span>() {
        System.<span class="keyword">out</span>.<span class="method">println</span>(<span class="string">"Driving a sedan car"</span>);
    }
}

<span class="keyword">class</span> <span class="class">SUVCar</span> <span class="keyword">implements</span> <span class="class">Car</span> {
    <span class="keyword">public</span> <span class="keyword">void</span> <span class="method">drive</span>() {
        System.<span class="keyword">out</span>.<span class="method">println</span>(<span class="string">"Driving an SUV car"</span>);
    }
}

<span class="keyword">// 工厂类</span>
<span class="keyword">class</span> <span class="class">CarFactory</span> {
    <span class="keyword">public</span> <span class="class">Car</span> <span class="method">createCar</span>(<span class="type">String</span> type) {
        <span class="keyword">if</span> (type.<span class="method">equals</span>(<span class="string">"sedan"</span>)) {
            <span class="keyword">return</span> <span class="keyword">new</span> <span class="class">SedanCar</span>();
        } <span class="keyword">else</span> <span class="keyword">if</span> (type.<span class="method">equals</span>(<span class="string">"suv"</span>)) {
            <span class="keyword">return</span> <span class="keyword">new</span> <span class="class">SUVCar</span>();
        } <span class="keyword">else</span> {
            <span class="keyword">throw</span> <span class="keyword">new</span> <span class="class">IllegalArgumentException</span>(<span class="string">"Invalid car type"</span>);
        }
    }
}

<span class="keyword">public</span> <span class="keyword">class</span> <span class="class">FactoryPatternDemo</span> {
    <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> <span class="method">main</span>(<span class="type">String</span>[] args) {
        <span class="class">CarFactory</span> factory = <span class="keyword">new</span> <span class="class">CarFactory</span>();
        <span class="class">Car</span> sedan = factory.<span class="method">createCar</span>(<span class="string">"sedan"</span>);
        <span class="class">Car</span> suv = factory.<span class="method">createCar</span>(<span class="string">"suv"</span>);

        sedan.<span class="method">drive</span>();
        suv.<span class="method">drive</span>();
    }
}</code></pre>
            </div>
            
            <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mb-8">
                <div class="flex">
                    <div class="flex-shrink-0">
                        <i class="fas fa-info-circle text-blue-500 text-xl mt-1"></i>
                    </div>
                    <div class="ml-3">
                        <h3 class="text-sm font-medium text-blue-800">代码解析</h3>
                        <div class="mt-2 text-sm text-blue-700">
                            <p>这个示例展示了工厂模式的基本结构：</p>
                            <ul class="list-disc pl-5 mt-1 space-y-1">
                                <li>定义产品接口(Car)和具体产品类(SedanCar, SUVCar)</li>
                                <li>创建工厂类(CarFactory)封装对象创建逻辑</li>
                                <li>客户端通过工厂类获取产品实例，而不直接实例化具体类</li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </section>

        <!-- Visualization Section -->
        <section class="mb-16">
            <div class="flex items-center mb-8">
                <div class="w-1 h-12 bg-blue-500 mr-4"></div>
                <h2 class="text-3xl font-bold">模式结构</h2>
            </div>
            
            <div class="bg-white p-6 rounded-xl shadow-md">
                <div class="mermaid">
                    classDiagram
                    class Client
                    class Factory {
                        +createProduct() Product
                    }
                    class Product {
                        <<interface>>
                        +operation()
                    }
                    class ConcreteProductA {
                        +operation()
                    }
                    class ConcreteProductB {
                        +operation()
                    }
                    
                    Client --> Factory
                    Client --> Product
                    Factory ..> Product
                    Product <|-- ConcreteProductA
                    Product <|-- ConcreteProductB
                </div>
                
                <div class="mt-6 grid md:grid-cols-3 gap-4">
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-blue-600 mb-2">工厂(Factory)</h4>
                        <p class="text-sm text-gray-600">负责创建产品对象的接口或抽象类</p>
                    </div>
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-blue-600 mb-2">具体工厂(ConcreteFactory)</h4>
                        <p class="text-sm text-gray-600">实现工厂接口，负责创建具体产品</p>
                    </div>
                    <div class="bg-gray-50 p-4 rounded-lg">
                        <h4 class="font-semibold text-blue-600 mb-2">产品(Product)</h4>
                        <p class="text-sm text-gray-600">定义工厂创建的对象的接口</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Conclusion Section -->
        <section class="mb-16">
            <div class="bg-blue-50 rounded-xl p-8 text-center">
                <div class="max-w-2xl mx-auto">
                    <i class="fas fa-check-circle text-blue-500 text-4xl mb-4"></i>
                    <h2 class="text-2xl font-bold text-gray-800 mb-4">工厂模式的精髓</h2>
                    <p class="text-gray-700 mb-6">工厂设计模式帮助我们实现了对象的创建与使用分离，提高了代码的可维护性和灵活性。通过合理使用工厂模式，我们能够更加优雅地构建可扩展的系统。</p>
                    <a href="#" class="inline-flex items-center px-6 py-3 border border-transparent text-base font-medium rounded-md shadow-sm text-white bg-blue-600 hover:bg-blue-700 transition duration-300">
                        <i class="fas fa-book mr-2"></i> 深入学习设计模式
                    </a>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="max-w-4xl mx-auto px-4 sm:px-6 lg:px-8">
            <div class="text-center">
                <h3 class="text-xl font-semibold text-white mb-4">技术小馆</h3>
                <p class="mb-6">探索编程艺术，分享技术智慧</p>
                <div class="flex justify-center space-x-4">
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition duration-300">
                        <i class="fas fa-globe text-lg"></i>
                        <span class="ml-2">www.yuque.com/jtostring</span>
                    </a>
                </div>
            </div>
            <div class="mt-8 pt-8 border-t border-gray-800 text-center text-sm text-gray-400">
                <p>© 2023 技术小馆. 版权所有.</p>
            </div>
        </div>
    </footer>

    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```